import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
function getName() {
  let defaultName = "";
  if (localStorage.getItem("name")) {
    defaultName = localStorage.getItem("name");
  }
  return defaultName;
}
export default new Vuex.Store({
  state: {
    name: getName()
  },
  mutations: {
    changeName(state, name) {
      // console.log(name);
      state.name = name;
      localStorage.setItem("name", name)
    }
  },
  actions: {
  },
  modules: {
  }
})
